/*
 * LdapManager: net.lc4ever.framework.orm.dao.Pager.java Create On 2010-2-2 下午06:14:53 By Q-Wang
 * $Revision: 1.1 $
 */
package com.ctvit.framework.dao;

import java.io.Serializable;
import java.util.List;

/**
 *
 *
 * @author Q-Wang
 */
public class Pager<T extends Serializable> implements Serializable {
	private List<T> result;
	private int count;
	private int pageSize = 20;
	private int pageNo = 0;
	private T query;
	/**
	 * @return the result
	 */
	public List<T> getResult() {
		return result;
	}
	/**
	 * @param result the result to set
	 */
	public void setResult(List<T> result) {
		this.result = result;
	}
	/**
	 * @return the count
	 */
	public int getCount() {
		return count;
	}
	/**
	 * @param count the count to set
	 */
	public void setCount(int count) {
		this.count = count;
	}
	/**
	 * @return the pageSize
	 */
	public int getPageSize() {
		return pageSize;
	}
	/**
	 * @param pageSize the pageSize to set
	 */
	public void setPageSize(int pageSize) {
		if (pageSize>0) {
			this.pageSize = pageSize;
		}
	}
	/**
	 * @return the pageNo
	 */
	public int getPageNo() {
		return pageNo;
	}
	/**
	 * @param pageNo the pageNo to set
	 */
	public void setPageNo(int pageNo) {
		this.pageNo = pageNo;
	}
	/**
	 * @return the query
	 */
	public T getQuery() {
		return query;
	}
	/**
	 * @param query the query to set
	 */
	public void setQuery(T query) {
		this.query = query;
	}
	public int getPageCount() {
		return count==0?0:(count-1)/pageSize+1;
	}
	public int offset() {
		return pageNo*pageSize;
	}
	public void next() {
		pageNo++;
	}
}
